<template>
	<jk-dialog
		v-model="showDialog"
		title="详情-设备"
		width="1100px"
		:show-content-loading="showLoading"
		:show-confirm-btn="false"
		:show-cancel-btn="false"
		:show-close-btn="true"
		@on-close="onVisibleChange(false)"
		@on-visible-change="onVisibleChange"
	>
		<el-form ref="ruleForm" :model="ruleForm" :show-message="false" label-width="120px">
			<el-row ref="box1" class="flex-start-center-wrap">
				<el-col :span="8">
					<el-form-item label="编码：" class="margin-bottom-10">
						<span class="read-only-2">{{ ruleForm.code }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="名称：" class="margin-bottom-10">
						<span class="read-only-2">{{ ruleForm.name }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="后道机台编号：" class="margin-bottom-10">
						<span class="read-only-2">{{ ruleForm.ltMachineName }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="设备类别：" class="margin-bottom-10">
						<span class="read-only-2">{{ ruleForm.typeName }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="工序：" class="margin-bottom-10">
						<span class="read-only-2">{{ ruleForm.processName }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="设备机型：" class="margin-bottom-10">
						<span class="read-only-2">{{ ruleForm.machineModelName }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="锭数：" class="margin-bottom-10">
						<span class="read-only-2">{{ ruleForm.spinCount }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="单价：" class="margin-bottom-10">
						<span class="read-only-2">{{ ruleForm.unitPrice }}</span>
					</el-form-item>
				</el-col>
				<el-col :span="8">
					<el-form-item label="所属区域：" class="margin-bottom-10">
						<span class="read-only-2">{{ ruleForm.workshopName }}</span>
					</el-form-item>
				</el-col>
				<!--<el-col :span="8">
                    <el-form-item label="状态：" prop="state" class="margin-bottom-10">
                        <jk-common-status :status="ruleForm.auditState"></jk-common-status>
                    </el-form-item>
                </el-col>-->
			</el-row>
			<el-tabs v-model="activeTab" type="border-card">
				<el-tab-pane label="基本信息">
					<el-row class="flex-start-center-wrap">
						<el-col :span="8">
							<el-form-item label="生产厂商：" prop="manufacturer" class="margin-bottom-10">
								<span class="read-only-2">{{ ruleForm.manufacturer }}</span>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="出厂编号：" class="margin-bottom-10">
								<span class="read-only-2">{{ ruleForm.productionCode }}</span>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="出厂日期：" class="margin-bottom-10">
								<span class="read-only-2">{{ ruleForm.productionDate }}</span>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="是否单锭：" class="margin-bottom-10">
								<el-radio-group v-model="ruleForm.ifSpinOutput" disabled>
									<el-radio :label="true">是</el-radio>
									<el-radio :label="false">否</el-radio>
								</el-radio-group>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="是否排产：" prop="ifScheduling" class="margin-bottom-10">
								<el-radio-group v-model="ruleForm.ifScheduling" disabled>
									<el-radio :label="true">是</el-radio>
									<el-radio :label="false">否</el-radio>
								</el-radio-group>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="是否样机：" class="margin-bottom-10">
								<el-radio-group v-model="ruleForm.ifTest" disabled>
									<el-radio :label="true">是</el-radio>
									<el-radio :label="false">否</el-radio>
								</el-radio-group>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="是否监控：" class="margin-bottom-10">
								<el-radio-group v-model="ruleForm.ifMonitoring" disabled>
									<el-radio :label="true">是</el-radio>
									<el-radio :label="false">否</el-radio>
								</el-radio-group>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="表数单位：" class="margin-bottom-10">
								<el-radio-group v-model="ruleForm.useMachineOutputKg" disabled>
									<el-radio :label="true">公斤</el-radio>
									<el-radio :label="false">米</el-radio>
								</el-radio-group>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="是否换行：" class="margin-bottom-10">
								<el-radio-group v-model="ruleForm.ifLineBreak" disabled>
									<el-radio :label="true">是</el-radio>
									<el-radio :label="false">否</el-radio>
								</el-radio-group>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="系数：" class="margin-bottom-10">
								<span class="read-only-2">{{ ruleForm.outputRatio }}</span>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="管重：" class="margin-bottom-10">
								<span class="read-only-2">{{ ruleForm.pipeQty }}</span>
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="排序：" class="margin-bottom-10">
								<span class="read-only-2">{{ ruleForm.sortNum }}</span>
							</el-form-item>
						</el-col>
						<el-col :span="24">
							<el-form-item label="备注：" prop="remark" class="margin-bottom-10">
								<el-input v-model="ruleForm.remark" disabled type="textarea" :rows="2" placeholder="备注" />
							</el-form-item>
						</el-col>
					</el-row>
				</el-tab-pane>
				<el-tab-pane label="锭组">
					<jk-table border :data="ruleForm.spinGroupList" :height="dialogTableHeight - 100">
						<vxe-column title="序号" align="center" type="seq" :width="60" />
						<vxe-column title="开始锭号" align="right" field="startSpinNumber" :min-width="100"></vxe-column>
						<vxe-column title="结束锭号" align="right" field="endSpinNumber" :min-width="100"></vxe-column>
					</jk-table>
				</el-tab-pane>
				<el-tab-pane label="监控参数">
					<jk-table border :data="ruleForm.monitoringParams" :height="dialogTableHeight - 80">
						<vxe-column title="序号" align="center" type="seq" :width="60"></vxe-column>
						<vxe-column title="点位" field="signalName" :min-width="100"></vxe-column>
						<vxe-column title="别名" field="typeName" :min-width="100"></vxe-column>
						<vxe-column title="纺纱方式" field="spinTypeName" :width="100"></vxe-column>
						<vxe-column title="单位朝向" field="spinTypeName" :width="90">
							<template slot-scope="scope">
								<span>{{ scope.row.unitLocal ? '左' : '右' }}</span>
							</template>
						</vxe-column>
						<vxe-column title="下限值" align="right" field="minValue" :min-width="100"></vxe-column>
						<vxe-column title="上限值" align="right" field="maxValue" :min-width="100"></vxe-column>
						<vxe-column title="误差范围" align="right" field="errorRange" :min-width="100"></vxe-column>
						<vxe-column title="是否监控" align="center" field="ifMonitoring" :width="70">
							<template slot-scope="scope">
								<span>{{ scope.row.ifMonitoring ? '是' : '否' }}</span>
							</template>
						</vxe-column>
						<vxe-column title="是否显示" align="center" field="ifShow" :width="70">
							<template slot-scope="scope">
								<span>{{ scope.row.ifShow ? '是' : '否' }}</span>
							</template>
						</vxe-column>
					</jk-table>
				</el-tab-pane>
			</el-tabs>

		</el-form>
	</jk-dialog>
</template>

<script>
    import calHeight from '/src/mixins/cal-dialog-height';
    import { machinemanagerMachineGet } from '../../../../api/machine/machineArchives';

    export default {
        name: 'MachineArchives',
        props: {
            dialogState: {
                type: Boolean,
                default: false
            },
            dataId: {
                type: [String, Number],
                default: ''
            }
        },
        mixins: [calHeight],
        data() {
            return {
                activeTab: '0',
                showDialog: false,
                showLoading: true,
                ruleForm: {}
            };
        },
        methods: {
            onVisibleChange(e) {
                this.$emit('on-visible-change', e);
                if (!e) {
                    Object.assign(this.$data, this.$options.data());
                }
            },
            getDetailRequest() {
                this.showLoading = true;
                return machinemanagerMachineGet({ id: this.dataId }).then(res => {
                    this.showLoading = false;
                    if (res.data.status === 200) {
                        this.ruleForm = res.data.res;
                    }
                });
            }
        },
        watch: {
            dialogState(newVal) {
                this.showDialog = newVal;
                if (newVal && this.dataId) {
                    this.getDetailRequest();
                }
            }
        }
    };
</script>
